<template>
  <div>
    <div class="werapp">
      <h1>商品详情</h1>
      <div class="box-item">
        <p>
          <b>商品名称：</b
          ><el-input
            type="text"
            v-model="model.name"
            placeholder="请输入商品名称"
            class="box-name"
          />
        </p>
        <p>
          <b>商品描述：</b
          ><el-input
            type="text"
            v-model="model.subtitle"
            placeholder="请输入商品描述"
            class="box-name"
          />
        </p>
        <p>
          <b>当前状态：</b
          ><el-input
            type="text"
            v-if="!model.subtitle"
            placeholder="请输入商品描述"
            class="box-name"
            value="已下架"
          ></el-input>
          <el-input
            type="text"
            v-else
            placeholder="请输入商品描述"
            class="box-name"
            value="在售"
          ></el-input>
        </p>
        <p>
          <b>所有分类：</b>
          <el-select v-model="model.categoryId" placeholder="请选择一级品类">
            <el-option
              v-for="item in options"
              :key="item.value"
              :label="item.name"
              :value="item.name"
            >
            </el-option>
          </el-select>
          <!-- <el-select v-model="value" placeholder="请选择二级品类">
            <el-option
              v-for="item in options1"
              :key="item.value"
              :label="item.name"
              :value="item.name"
            >
            </el-option>
          </el-select> -->
        </p>
        <p>
          <b>商品价格：</b
          ><el-input
            type="number"
            v-model="model.price"
            placeholder="价格"
            class="box-price"
          >
            <el-button slot="append">元</el-button>
          </el-input>
        </p>
        <p>
          <b>商品库存：</b
          ><el-input
            type="number"
            v-model="model.stock"
            placeholder="库存"
            class="box-price"
          >
            <el-button slot="append">元</el-button>
          </el-input>
        </p>
        <p>
          <b>商品图片：</b> <br />
          <img
            class="image"
            v-if="model.mainImage"
            :src="model.imageHost + model.mainImage"
            alt
            srcset
          />
          <img class="image" src="http://img.happymmall.com/" alt="" />
        </p>
        <p>
          <b>商品详情：</b>
          <b v-html="model.detail"></b>
        </p>
      </div>
    </div>
  </div>
</template>

<script>
import { checkdetails, getcategory } from "../../../http/index.js";
export default {
  data() {
    return {
      value: "",
      model: {},
      textarea: "",
      options: [],
    };
  },
  created() {
    console.log(this.$route.query.data);
    checkdetails({ productId: this.$route.query.data }).then((res) => {
      console.log(res);
      this.model = res.data.data;
    });
    getcategory().then((res) => {
      console.log(res);
        this.options = res.data.data;
    });
  },
};
</script>

<style lang="scss" scoped>
.werapp {
  padding: 15px 30px;
  h1 {
    font-size: 36px;
  }
  .box-item {
    .box-name {
      width: 300px;
      padding: 10px 0;
    }
    .box-price {
      width: 150px;
      padding: 10px 0;
    }
    .image {
      width: 100px;
      height: 100px;
    }
  }
}
</style>